package com.boot.dog.rest.core;

import com.boot.dog.common.util.ExcelUtil;
import com.boot.dog.entities.ao.UserAo;
import com.boot.dog.entities.pojo.User;
import com.boot.dog.service.UserService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Author: MaxLv
 * @Date: 2020/1/16
 */
@RestController
@RequestMapping("/core/export")
@AllArgsConstructor
public class ExportRest {

    private final UserService userService;

    @PostMapping("/exportUser")
    @ApiOperation(value = "导出用户信息")
    public void exportUser(@RequestBody UserAo ao, HttpServletResponse response) {
        List<User> users = userService.getUserList(ao);
        ExcelUtil.exportExcel(users, "用户信息", "用户信息", User.class, response);
    }
}
